-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[discover] Less field list loading #147825
[discover] Less field list loading #147825
Conversation
@@ -93,13 +93,6 @@ export function DiscoverMainRoute(props: Props) { | |||
return; | |||
} | |||
|
|||
const defaultDataView = await data.dataViews.getDefaultDataView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality duplicates what dataViews.hasData
is doing. If it doesn't work, it should be fixed.
@@ -111,7 +104,6 @@ export function DiscoverMainRoute(props: Props) { | |||
|
|||
const ipList = ip.list; | |||
const dataViewData = resolveDataView(ip, nextSavedSearch.searchSource, toastNotifications); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refreshFields
has been added to the data view loading functions - previously the data view would be loaded, triggering the first field list load, and then it would be loaded again to make sure it was fresh.
@@ -38,9 +38,6 @@ export function findDataViewById( | |||
dataViews: DataViewListItem[], | |||
id: string | |||
): DataViewListItem | undefined { | |||
if (!Array.isArray(dataViews) || !id) { | |||
return; | |||
} | |||
return dataViews.find((o) => o.id === id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this code since its enforced by type safety. Let me know if there's some reason why this shouldn't be done.
// try to fetch adhoc data view first | ||
try { | ||
const fetchedDataView = fetchId ? await dataViews.get(fetchId) : undefined; | ||
fetchedDataView = fetchId ? await dataViews.get(fetchId) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this code was loading a data view, checking if it was adhoc, then tossing the result. Now we hold on to it in case its the data view we wanted to load.
@@ -122,12 +120,14 @@ export async function loadDataView( | |||
} catch (e) {} | |||
|
|||
// fetch persisted data view | |||
const actualId = getDataViewId(fetchId, dataViewList, config.get('defaultIndex')); | |||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need getDataViewId
because dataViews.getDefaultDataView
does the work - it provides the default data view and if it doesn't exist then it sets another default and if there aren't any data views...well, thats what the hasData
check is for.
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
@mattkime This is a great improvement. Are we able to calculate e.g how much speed improvement this gives on a large data set ? |
Somewhere between 50% and 33% faster, although our goal should be to load the field list without a noticeable delay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved! |
More speed 👍 |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unified search changes LGTM, great improvement :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thx for this improvement 🙏 very appreciated!
## Summary Looking at why Discover was loading data view field lists were loading more than needed, I found more reasons than actual field list loads occurring but I think they're all deserving of improvement. - Discover was loading the default data view to see if there was an existing data view. We can rely on the `hasData` api instead. - We were loading a data view and then refreshing the field list. If the data view was being loaded fresh, its meant the field list was loaded twice. Field list refresh has been integrated into the dataViews api. - We were loading a data view, checking it if was adhoc, and tossing it if it wasn't. Now we keep the reference. Previously on page load, discover would make 3 calls to `fields_for_wildcard`, now it makes two. It loads all the field with one request and it makes an additional request where it applies the current filter to find relevant fields. Closes elastic#147744
## Summary Looking at why Discover was loading data view field lists were loading more than needed, I found more reasons than actual field list loads occurring but I think they're all deserving of improvement. - Discover was loading the default data view to see if there was an existing data view. We can rely on the `hasData` api instead. - We were loading a data view and then refreshing the field list. If the data view was being loaded fresh, its meant the field list was loaded twice. Field list refresh has been integrated into the dataViews api. - We were loading a data view, checking it if was adhoc, and tossing it if it wasn't. Now we keep the reference. Previously on page load, discover would make 3 calls to `fields_for_wildcard`, now it makes two. It loads all the field with one request and it makes an additional request where it applies the current filter to find relevant fields. Closes elastic#147744
Summary
Looking at why Discover was loading data view field lists were loading more than needed, I found more reasons than actual field list loads occurring but I think they're all deserving of improvement.
hasData
api instead.Previously on page load, discover would make 3 calls to
fields_for_wildcard
, now it makes two. It loads all the field with one request and it makes an additional request where it applies the current filter to find relevant fields.Closes #147744